<?php
error_reporting ( 0 );
require_once ("../in/tren.php");
$tit = 'Phòng Chat - Tán Gẫu - Trò Chuyện';
header ( "content-type:text/html; charset=UTF-8" );
@session_start ();
echo '<div class="navigation"><b>Chat Room</b></div><div align="right"><div style="border-top: 3px solid #13cfeb;"></div></div></div>';
$ql = 'op';
if ($set ['chat'] != $ql && $taikhoan ['quyen'] != 2) {
	echo '<div class="main_menu"><b style="color:red">Phòng Chat Tạm Thời Đóng Cửa</b></div>';
} else {
	echo '<div class="main_menu"><form action="chat.php?chat=viet" method="post"><textarea cols="20" rows="2" name="noidung"></textarea><input type="submit" value="Gửi">  | <a href="?rf=' . rand ( 1, 20 ) . '">Tải Lại</a> | <a href="bb.php">BBCode</a></form></div>';
}
if (! $_GET ['page']) {
	$_GET ['page'] = '1';
}
$page = $_GET ['page'];
$chat = "SELECT count(*) FROM chat";
$total_chat = mysql_query ( $chat );
$num_chat = 10;
$num_chat = ( int ) $num_chat;
$lip = $page * 10;
$lip = $lip - 10;
$chat = "SELECT * FROM chat ORDER BY id DESC LIMIT $lip,$num_chat";
$soob = mysql_query ( $chat );
$count = mysql_result ( $total_chat, 0 );
if ($count < 1) {
	echo '<div class="main_menu"><font color="red">Phòng Chat Trống</font></div>';
} else
	while ( $v = mysql_fetch_array ( $soob ) ) {
		$id_chat = trim ( $v ['id'] );
		$id_chat = ( int ) $id_chat;
		$ten = $v ['ten'];
		$noidung = bbcode ( trim ( $v ['noidung'] ) );
		$tg = $v ['thoigian'];
		$i = $v ['ip'];
		echo '<div style="border-left:1px solid #00a6ff; border-bottom:1px solid #00a6ff; border-right:1px solid #00a6ff"><div style=" background:white; padding:2px; margin:2px"><div align="left"><div class="main_menu"><span style="color:#ff0099;">&bull;</span><b style="color:#00EEEE">' . $ten . '</b> <span style="text-align:right">[<a href="chat.php?chat=q&id=' . $id_chat . '">Trích</a>]</span></div><font color="#555555">' . $noidung . '<br>(' . $tg . ')</font>';
		if ($taikhoan ['quyen'] == 2) {
			echo '<br>IP: ' . $i . '<br>____________<br>[<a href="chat.php?chat=sua&id=' . $id_chat . '"><font color="blue">Sửa</font></a> | <a href="chat.php?chat=xoa&id=' . $id_chat . '"><font color="blue">Xóa</font></a>]';
		}
		echo '</div></div></div>';
	}
if ($count > 10) {
	echo '<div class="main_menu"><b>Trang</b>: ';
	$onpage = 10;
	$pages = ceil ( $count / $onpage );
	showLP ( $pages );
	$count_chat = $count;
	echo '</div>';
	if ($taikhoan ['quyen'] == 2) {
		echo '<div class="main_menu">[<a href="chat.php?chat=xoahet"><b class="red">Làm Sạch Phòng</b></a>]</div>';
	}
}
require_once ("../in/duoi.php");
?>
